package org.hxyjs.service.impl;


import org.hxyjs.dao.ActivityprizesDao;
import org.hxyjs.dto.DTO;
import org.hxyjs.dto.MessageEnum;
import org.hxyjs.entity.Activityprizes;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.ActivityprizesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@Service("ActivityprizesService")
public class ActivityprizesServiceImpl implements ActivityprizesService {
    @Resource
    ActivityprizesDao activityprizesDao;
    @Override
    public DTO<Activityprizes> getAllActivityprizess()  throws Exception{
        List<Activityprizes> activityprizess = activityprizesDao.getAllActivityprizess();
        MessageEnum messageEnum  = Optional.ofNullable(activityprizess).isPresent()?MessageEnum.GETACTIVITYPRIZESSUCCESS: MessageEnum.GETACTIVITYPRIZESFAIL;
        return new DTO<Activityprizes>(messageEnum.getCode(),messageEnum.getMessage(),activityprizess);
    }

    @Override
    public DTO<Activityprizes> deleteActivityprizesByApno(String apno)  throws Exception{
        Integer result = activityprizesDao.deleteActivityprizesByApno(apno);
        MessageEnum messageEnum  =result> 0?MessageEnum.DELETEACTIVITYPRIZESSUCCESS:MessageEnum.DELETEACTIVITYPRIZESFAIL;
        return new DTO<Activityprizes>(messageEnum.getCode(),messageEnum.getMessage());
    }

    @Override
    public DTO<Activityprizes> updateActivityprizesByApno(Activityprizes activityprizes)  throws Exception{
        Integer result = activityprizesDao.updateActivityprizesByApno(activityprizes);
        MessageEnum messageEnum  =result> 0?MessageEnum.UPDATEACTIVITYPRIZESSUCCESS:MessageEnum.UPDATEACTIVITYPRIZESFAIL;
        return new DTO<Activityprizes>(messageEnum.getCode(),messageEnum.getMessage());
    }

    @Override
    public DTO<Activityprizes> addActivityprizes(Activityprizes activityprizes) throws Exception {
        Integer result = activityprizesDao.addActivityprizes(activityprizes);
        MessageEnum messageEnum  = result> 0?MessageEnum.ADDACTIVITYPRIZESSUCCESS:MessageEnum.ADDACTIVITYPRIZESFAIL;
        return new DTO<Activityprizes>(messageEnum.getCode(),messageEnum.getMessage());
    }
    @Override
    public DTO<Activityprizes> getActivityprizesByPage(PageInfo pageInfo ) throws Exception {
        List<Activityprizes> activityprizess = activityprizesDao.getActivityprizesByPage(pageInfo);
        MessageEnum messageEnum  = Optional.ofNullable(activityprizess).isPresent()?MessageEnum.GETACTIVITYPRIZESSUCCESS: MessageEnum.GETACTIVITYPRIZESFAIL;
        return new DTO<Activityprizes>(messageEnum.getCode(),messageEnum.getMessage(),activityprizess,pageInfo);
    }
    
    
}
